<?php
	include _ROOT . '/config.php';

	include _ROOT . '/application/controller.class.php';
	include _ROOT . '/application/registry.class.php';
	include _ROOT . '/application/database.class.php';
	include _ROOT . '/application/configuration.class.php';
	include _ROOT . '/application/router.class.php';
	include _ROOT . '/application/auth.class.php';
	include _ROOT . '/application/template.class.php';
	include _ROOT . '/application/module.class.php';

	function __autoload($class)
	{
		$file = strtolower($class);
		$file = _ROOT . '/model/' . $file;
		if(file_exists($file) == false)
		{
			return false;
		}
		include $file;
	}

	define('CONTROLLER',	'74873649264359236495726051937409162587623845686573465836583997');

	$registry = new Registry();

	$registry->db = Database::getInstance(DB_HOSTNAME, DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_DRIVER);

	$registry->cfg = new Configuration($registry->db);

	// Change tamplate to admin template
	$registry->cfg->template = $registry->cfg->admintemplate;

	$registry->router = new Router($registry);

	$registry->auth = new Auth($registry);

	$registry->router->setPath(_ROOT . '/admin/controller');

	$registry->template = new Template($registry);

	$registry->module = new Module();

	$templatepath = $registry->cfg->basedir . 'templates/' . $registry->cfg->template . '/';
	define('_TEMPLATE', $templatepath);

	$registry->router->loader();
?>